package com.lancoo.dictionary.data.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Copyright (C) 2016 LANCOO. All Rights Reserved.
 * Created by 刘孟孟 on 2016/10/12.
 */

public class DicSearchBehavior implements Parcelable{

    /**
     * 所查单词
     */
    private String searchWord;

    public  static final int SOURCE_HTTP = 0;
    public  static final int SOURCE_DB = 1;
    /**
     * 数据来源,联网/本地数据库
     */
    private int dataSource;

    /**
     * 搜索该词的时间，毫秒数
     */
    private long searchTime;

    /**
     * 查询是否有结果
     */
    private boolean hasResult;

    public String getSearchWord() {
        return searchWord;
    }

    public void setSearchWord(String searchWord) {
        this.searchWord = searchWord;
    }

    public int getDataSource() {
        return dataSource;
    }

    public void setDataSource(int dataSource) {
        this.dataSource = dataSource;
    }

    public long getSearchTime() {
        return searchTime;
    }

    public void setSearchTime(long searchTime) {
        this.searchTime = searchTime;
    }

    public boolean isHasResult() {
        return hasResult;
    }

    public void setHasResult(boolean hasResult) {
        this.hasResult = hasResult;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.searchWord);
        dest.writeInt(this.dataSource);
        dest.writeLong(this.searchTime);
        dest.writeByte(this.hasResult ? (byte) 1 : (byte) 0);
    }

    public DicSearchBehavior() {
    }

    protected DicSearchBehavior(Parcel in) {
        this.searchWord = in.readString();
        this.dataSource = in.readInt();
        this.searchTime = in.readLong();
        this.hasResult = in.readByte() != 0;
    }

    public static final Creator<DicSearchBehavior> CREATOR = new Creator<DicSearchBehavior>() {
        @Override
        public DicSearchBehavior createFromParcel(Parcel source) {
            return new DicSearchBehavior(source);
        }

        @Override
        public DicSearchBehavior[] newArray(int size) {
            return new DicSearchBehavior[size];
        }
    };

}
